New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API: Prevent large images from repeatedly crashing PHP on resize #2859
API: Prevent large images from repeatedly crashing PHP on resize #2859
Conversation
+1 to get this done as soon as possible great work @kinglozzer |
I think it’s probably important that we document this change if it’s accepted, it may be quite confusing to developers otherwise if images disappear (until we set up CMS messages or something). Would |
bump I don’t wanna spend any more time on this until I get a nod of approval from a core committer. Any other comments/criticisms are also welcome of course! 😉 |
bump can we please get this merged asap? |
bumpity bump :) Could this (or any other proposed fix for this issue) make it into 3.2? Not sure how far off we are. |
|
||
/** | ||
* If __destruct() is called, any attempted image manipulation must have succeeded, | ||
* so it can be removed from the cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't always true. HHVM at least still calls destructors after a fatal error.
Thanks Simon, I’d not considered that there might be inconsistencies with I guess you could argue that we can’t really be responsible for this - we just need to try to prevent, for example, parts of the CMS being inaccessible. So, should we:
|
sounds like a tricky issue. I for one actually do use Not sure if C is a good solution, but I am not that much into the the whole issue that I could speak to that (I don't know how accurate the approximation is, or how likely/unlikely it is that an error still occurs). |
A couple of options:
Given that it's not actually that important to remove items from the cache, I'd prefer the first option. |
I’ve moved the cache cleaning to @simonwelsh I’ve added |
Would be better to throw a more specific exception (so, a subclass) and then catch that so that the PHPUnit exception doesn't get caught. |
Tests updated :) |
API: Prevent large images from repeatedly crashing PHP on resize
Green button pushed! Now my slides are out of date... |
awesome! |
Thanks @simonwelsh |
This was removed as part of the SS4 assets refactor: silverstripe@be23989 Presumably @tractorcow didn’t feel it’s possible to retain this, because we don’t have local file handles required for getimagesize(). Since there’s getimagesizefromstring() as well (added in PHP 5.4), we just needed a different logic branch. Also makes the logic more resilient against missing GD resources on a backend. Lack of available memory for a resize is only one (new) reason, other edge cases were already causing these missing resources (e.g. an invalid file string). Original discussion: https://groups.google.com/forum/m/#!topic/silverstripe-dev/B57a3KYeAVQ Pull request for 3.x: silverstripe#2859 More context: silverstripe#2569
See #2753 for more discussion.
This is a (late) follow up to the discussion here about GD crashing when attempting to open large or high DPI images.
The Google Group discussion involved ideas around “image unavailable” icons in the CMS, this setup (by storing which manipulation failed) will hopefully pave the way for that functionality to be added later, while addressing the immediate issue of completely crashing entire sections of websites.
Implements the same method for checking available memory as #2569, though it’s different to the method Ingo suggested. I’m not really sure which is more robust, the method in the php.net comments doesn’t take into account that bits and channels aren’t always present in the image info.
Marked as an API change as I’ve added a few methods to the
Image_Backend
interface.Doesn’t cause any issues with the CMS, the images just don’t appear for now:
All comments welcome.